package com.woniuxy.creditsystem.mortgagemag.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.creditsystem.common.bean.VehicleFind;
import com.woniuxy.creditsystem.common.bean.VehicleInfo;
import com.woniuxy.creditsystem.common.mapper.VehicleMapper;

import com.woniuxy.creditsystem.mortgagemag.service.IVehicleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Transactional(readOnly = true)
@Service
public class VehicleServiceImpl  implements IVehicleService {

    @Resource
    private VehicleMapper vehicleMapper;





    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int saveVehicleInfo(VehicleInfo vehicleInfo) {
        return vehicleMapper.saveVehicleInfo(vehicleInfo);
    }


    @Override
    public VehicleInfo getOneById(Long id) {
        return vehicleMapper.getOneById(id);
    }

   @Override
        public PageInfo<VehicleInfo> findAllByParams(int pageNum, int pageSize,VehicleFind vehicleFind) {
        return PageHelper.startPage(pageNum,pageSize).
                doSelectPageInfo(()->vehicleMapper.findAllByParams(vehicleFind));
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int updateVehicle(VehicleInfo vehicleInfo) {
        return vehicleMapper.updateVehicle(vehicleInfo);
    }


    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int deleteVehicle(Long id) {
        return vehicleMapper.deleteVehicle(id);
    }







   /* @Override
    public List<VehicleInfo> findAll() {
        return vehicleMapper.findAll();
    }*/


}
